package Logic;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class Encryptor {
	MessageDigest algorithm;
	public Encryptor()
	{
		try{
			algorithm = MessageDigest.getInstance("MD5");
		}
		catch(NoSuchAlgorithmException nsae){}
	}
	
	public String MD5Password(String password)
	{
		try{
			byte[] defaultBytes = password.getBytes();
			algorithm.reset();
			algorithm.update(defaultBytes);
			byte messageDigest[] = algorithm.digest();
			StringBuffer hexString = new StringBuffer();
			for (int i=0;i<messageDigest.length;i++) {
				hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
			}
			
			return hexString.toString();			
		}
		catch (Exception E){
			System.out.println("problem");		    
		}
		return null;
	}				
}